Open files on share / pc / internet

Hallo, I tried to create a button "Help" and link it with a Help document (*.doc) which is saved on the project share.

The creation of the button seems easy, the difficulties appear when I try to write the function which opens the *.doc. Has anyone a tipp for me e.g. keywords or something?

Thanks in advance!
SystemAdmin - Wed Aug 12 04:25:38 EDT 2009

Re: Open files on share / pc / internet
Peter_Albert - Wed Aug 12 05:16:14 EDT 2009

You can use the "system" perm:

Try the following in your button callback routine:

if (platform=="WIN32"}{system "C:\\Program Files\\Microsoft Office\\OFFICE11\\WINWORD.EXE \"<complete_path_to_your_word_file>\""}

 


Of course you must first make sure that the Word executable really is in "C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE", otherwise you have to correct that part of the above call, and secondly you must make sure that you escape the backslashes in <complete_path_to_your_word_file>, as done for the path to winword.exe.

For more ambitious tasks there is the whole world of OLE automatisation, but for just opening a Word file the above should be o.k..

Regards,

Peter

 

Re: Open files on share / pc / internet
llandale - Wed Aug 12 12:14:57 EDT 2009

Yes "system". But since your computer no doubt recognizes *.doc files as belonging to MS-Word,
system("p:/MyFolder/MyHelpFile.doc")
should be enough.

Notice however that if someone else has it open this may not work.

  • Louie

Doh! I've got some massive function that looks for the 'winword.exe' and 'excel.exe' files on the computer, containing a fairly long list of places to look, including Registry values. I really should take my own advise above and abandon all that.

Nuance: the 'system' command will return after it submits the requiest to the OS, it doesn't wait for the file to be displayed. That won't matter to you unless you figure to do something with the open Word file. There is also this command that will wait for it to actually finish loading. Other's have made this work but for some reason it doesn't work for me:

int win32SystemWait_(string commandString,string& sResult, int waitTime)

'waitTime' is in milliSeconds. Here are the return codes:

int syswaitSUCCESS_ (=0)
int syswaitPROCESSERROR_ (=1)
int syswaitTIMEOUT_ (=3)
waitTime parameters:
int syswaitPIPEFAULT_ (=2)
int syswaitINFINITE_ (=-1)